﻿<%@ Page Title="Add Reply" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="AddReply.aspx.vb" Inherits="BeachesInGreeceComplete.AddComment" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Add Reply</h2>
<div class="testclass1">
 <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
            DataKeyNames="Id" DataSourceID="SqlDataSource1" DefaultMode="Insert" 
            Height="50px" oniteminserted="DetailsView1_ItemInserted" Width="125px" 
            onitemcommand="DetailsView1_ItemCommand" OnItemInserting="DetailsView1_ItemInserting">
            <Fields>
                <asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" 
                    ReadOnly="True" SortExpression="Id" />
<asp:TemplateField HeaderText="Title" SortExpression="Title">
<ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
                    
</ItemTemplate>

    <EditItemTemplate>
        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
    </EditItemTemplate>
    <InsertItemTemplate>
        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
            ControlToValidate="TextBox2" CssClass="error" ErrorMessage="*"></asp:RequiredFieldValidator>
    </InsertItemTemplate>
</asp:TemplateField>
                <asp:TemplateField HeaderText="Reply" SortExpression="Comment">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("Comment") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Comment") %>'
                            TextMode="MultiLine"></asp:TextBox>
                    </EditItemTemplate>
                    <InsertItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Comment") %>'
                            TextMode="MultiLine"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                            ControlToValidate="TextBox1" CssClass="error" ErrorMessage="Add a Reply"></asp:RequiredFieldValidator>
                    </InsertItemTemplate>
                    <ControlStyle Height="150px" Width="200px" />
                    <HeaderStyle VerticalAlign="Top" />
                </asp:TemplateField>
                <asp:CommandField InsertText="Add Reply"
                    ShowInsertButton="True" ButtonType="Link"  />
            </Fields>
        </asp:DetailsView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:BeachConnectionString %>" 
            ProviderName="<%$ ConnectionStrings:BeachConnectionString.ProviderName %>"  
            DeleteCommand="DELETE FROM [Comments] WHERE [Id] = @Id" 
            InsertCommand="INSERT INTO [Comments] ([CommentsName], [Title], [Beaches_FK], [CommentsBody], [ReplyTo], [DateAdded]) VALUES (@Name, @Title, @Beaches_FK, @Comment, @ReplyTo, Now())" 
            SelectCommand="SELECT [Id], [Title], [CommentsName], [CommentsBody], [ReplyTo] FROM [Comments]" 
            UpdateCommand="UPDATE [Comments] SET [CommentsName] = @Name, [Title] = @Title, [Beaches_FK] = @Beaches_FK, [CommentsBody] = @Comment, [ReplyTo] = @ReplyTo WHERE [Id] = @Id">
            <DeleteParameters>
                <asp:Parameter Name="Id" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Title" Type="String" />
                <asp:Parameter Name="Beaches_FK" Type="Int32" />
                <asp:Parameter Name="Comment" Type="String" />
                <asp:QueryStringParameter Name="ReplyTo" QueryStringField="replyTo" 
                    Type="Int32" />
            </InsertParameters>
            <UpdateParameters>  
                <asp:Parameter Name="Name" Type="String" />
                <asp:Parameter Name="Title" Type="String" />
                <asp:Parameter Name="Beaches_FK" Type="Int32" />
                <asp:Parameter Name="Comment" Type="String" /> 
                <asp:Parameter Name="ReplyTo" Type="Int32" />
                <asp:Parameter Name="Id" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        </div>
</asp:Content>
